<template>
    <div>
        <nav-bar>
            <template v-slot:default>账号管理</template>
        </nav-bar>
        <div class="account">
            <van-cell title="用户账号" is-link :value="user.email" />
            <van-cell @click="updatePassword" title="修改登录密码" is-link value="" />
        </div>
    </div>
</template>

<script>
    import NavBar from '@/components/common/navbar/NavBar.vue';
    import { getUser } from '@/network/user';
    import { reactive,onMounted,toRefs } from 'vue';
    import { useRouter } from 'vue-router';
    export default {
        name:'Account',
        components:{
            NavBar,
        },
        setup(){
            const state=reactive({
                user:{}
            })
            const router=useRouter();
            onMounted(()=>{
                getUser().then(res=>{
                    console.log(res);
                    state.user=res;
                })
            })
            const updatePassword=()=>{
                router.push('/updatepwd')
            }
            // const updateEmail=()=>{
            //     router.push('/updatemail')
            // }
            return{
                ...toRefs(state),
                updatePassword,
                // updateEmail
            }

        }
    }

</script>

<style>
.account {
    margin-top: 45px;
}
.van-cell__title {
    text-align: left;
}
</style>